<html>
<head><meta charset="utf-8"><title>RA tree of dependencies visible symbols · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/RA.20tree.20of.20dependencies.20visible.20symbols.html">RA tree of dependencies visible symbols</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="176269050"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/RA%20tree%20of%20dependencies%20visible%20symbols/near/176269050" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Robert Sedlacek <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/RA.20tree.20of.20dependencies.20visible.20symbols.html#176269050">(Sep 21 2019 at 15:25)</a>:</h4>
<p>Hey everyone, hope I'm in the right place here for a RA question :)</p>
<p>I'm experimenting with RA trying to see if it's possible to make a CLI API/documentation browser. I'm currently wondering if there's a good way to get a tree of a (dependency) crates' publicly visible symbols and the names they are available as. Only played with things I got via <code>ra_batch::load_cargo</code> at the moment so I assumed I'm probably just missing knowledge of some parts.</p>



<a name="176269121"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/RA%20tree%20of%20dependencies%20visible%20symbols/near/176269121" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Mcnab <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/RA.20tree.20of.20dependencies.20visible.20symbols.html#176269121">(Sep 21 2019 at 15:27)</a>:</h4>
<p>Collect_deps in hir might have what you want</p>



<a name="176269191"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/RA%20tree%20of%20dependencies%20visible%20symbols/near/176269191" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Robert Sedlacek <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/RA.20tree.20of.20dependencies.20visible.20symbols.html#176269191">(Sep 21 2019 at 15:30)</a>:</h4>
<p>Hm, I can't seem to find that one in the repository</p>



<a name="176269397"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/RA%20tree%20of%20dependencies%20visible%20symbols/near/176269397" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Mcnab <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/RA.20tree.20of.20dependencies.20visible.20symbols.html#176269397">(Sep 21 2019 at 15:36)</a>:</h4>
<p>Actually, maybe you should trace completion from a crate root</p>



<a name="176269447"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/RA%20tree%20of%20dependencies%20visible%20symbols/near/176269447" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Mcnab <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/RA.20tree.20of.20dependencies.20visible.20symbols.html#176269447">(Sep 21 2019 at 15:36)</a>:</h4>
<p>Completion is somewhat similar to documentation in its requirements</p>



<a name="176269464"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/RA%20tree%20of%20dependencies%20visible%20symbols/near/176269464" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Robert Sedlacek <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/RA.20tree.20of.20dependencies.20visible.20symbols.html#176269464">(Sep 21 2019 at 15:37)</a>:</h4>
<p>You mean doing a completion run and just collect whatever it scans? Hadn't considered that, but yeah, it would need all the right mechanics anyway.</p>



<a name="176269468"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/RA%20tree%20of%20dependencies%20visible%20symbols/near/176269468" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Robert Sedlacek <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/RA.20tree.20of.20dependencies.20visible.20symbols.html#176269468">(Sep 21 2019 at 15:37)</a>:</h4>
<p>That's a good starting point, thanks :)</p>



<a name="176270694"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/RA%20tree%20of%20dependencies%20visible%20symbols/near/176270694" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/RA.20tree.20of.20dependencies.20visible.20symbols.html#176270694">(Sep 21 2019 at 16:11)</a>:</h4>
<p><span class="user-mention" data-user-id="236999">@Robert Sedlacek</span> that should be possible yeah, but, as usual, keep in mind that rust-analyzer is pretty incomplete</p>



<a name="176270738"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/RA%20tree%20of%20dependencies%20visible%20symbols/near/176270738" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/RA.20tree.20of.20dependencies.20visible.20symbols.html#176270738">(Sep 21 2019 at 16:12)</a>:</h4>
<p>We have code that walks module declarations here: <a href="https://github.com/rust-analyzer/rust-analyzer/blob/468e1d14c1a4b3d646207ae919082dc17753cd31/crates/ra_cli/src/analysis_stats.rs#L40-L45" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/blob/468e1d14c1a4b3d646207ae919082dc17753cd31/crates/ra_cli/src/analysis_stats.rs#L40-L45">https://github.com/rust-analyzer/rust-analyzer/blob/468e1d14c1a4b3d646207ae919082dc17753cd31/crates/ra_cli/src/analysis_stats.rs#L40-L45</a></p>



<a name="176270739"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/RA%20tree%20of%20dependencies%20visible%20symbols/near/176270739" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/RA.20tree.20of.20dependencies.20visible.20symbols.html#176270739">(Sep 21 2019 at 16:12)</a>:</h4>
<p>note that we don't handle visibility yet</p>



<a name="176270803"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/RA%20tree%20of%20dependencies%20visible%20symbols/near/176270803" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Robert Sedlacek <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/RA.20tree.20of.20dependencies.20visible.20symbols.html#176270803">(Sep 21 2019 at 16:14)</a>:</h4>
<p>Does that take reexports into consideration as well?</p>



<a name="176270813"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/RA%20tree%20of%20dependencies%20visible%20symbols/near/176270813" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Robert Sedlacek <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/RA.20tree.20of.20dependencies.20visible.20symbols.html#176270813">(Sep 21 2019 at 16:14)</a>:</h4>
<p>Ah, probably not. I actually used that code as template for my experiments :)</p>



<a name="176270956"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/RA%20tree%20of%20dependencies%20visible%20symbols/near/176270956" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/RA.20tree.20of.20dependencies.20visible.20symbols.html#176270956">(Sep 21 2019 at 16:18)</a>:</h4>
<p><span class="user-mention" data-user-id="236999">@Robert Sedlacek</span> <code>.declatations</code> is only for directly declared items. However, the info about reexports is there, it's just not exposed by this particular method. See the source code for <code>declarations</code>  method (in <code>code_model.rs</code>), it explicitelly filters-out imported items .</p>



<a name="176270974"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/RA%20tree%20of%20dependencies%20visible%20symbols/near/176270974" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Robert Sedlacek <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/RA.20tree.20of.20dependencies.20visible.20symbols.html#176270974">(Sep 21 2019 at 16:19)</a>:</h4>
<p><span class="user-mention" data-user-id="133169">@matklad</span>  Aah, thank you, I'll check that out</p>



<a name="176271095"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/RA%20tree%20of%20dependencies%20visible%20symbols/near/176271095" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/RA.20tree.20of.20dependencies.20visible.20symbols.html#176271095">(Sep 21 2019 at 16:22)</a>:</h4>
<p>Note that I think we don't handle visibility yet at all, and that might be a bigger problem.</p>



<a name="176271105"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/RA%20tree%20of%20dependencies%20visible%20symbols/near/176271105" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/RA.20tree.20of.20dependencies.20visible.20symbols.html#176271105">(Sep 21 2019 at 16:23)</a>:</h4>
<p>It shouldn't be hard to provide visbility info. INtegrating it correctly with name resolution would be harder, but not insurmontable.</p>



<a name="176271231"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/RA%20tree%20of%20dependencies%20visible%20symbols/near/176271231" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Robert Sedlacek <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/RA.20tree.20of.20dependencies.20visible.20symbols.html#176271231">(Sep 21 2019 at 16:26)</a>:</h4>
<p>Yeah, I'm probably still a bit too unfamiliar with the codebase for that one :) Though maybe I'll be closer when I tried out more now that I know about the reexports.</p>



<a name="176320585"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/RA%20tree%20of%20dependencies%20visible%20symbols/near/176320585" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/RA.20tree.20of.20dependencies.20visible.20symbols.html#176320585">(Sep 22 2019 at 18:19)</a>:</h4>
<p>just to make sure, have you seen <a href="https://github.com/rust-dev-tools/cargo-src" target="_blank" title="https://github.com/rust-dev-tools/cargo-src">https://github.com/rust-dev-tools/cargo-src</a>?</p>



<a name="176324458"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/RA%20tree%20of%20dependencies%20visible%20symbols/near/176324458" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Robert Sedlacek <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/RA.20tree.20of.20dependencies.20visible.20symbols.html#176324458">(Sep 22 2019 at 20:12)</a>:</h4>
<p><span class="user-mention" data-user-id="203546">@Laurențiu Nicola</span> I haven't seen that one yet, thanks!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>